<script>
function checkNum(obj)
{
 var re = /^-?[1-9]*(\.\d*)?$|^-?d^(\.\d*)?$/;
    if (!re.test(obj))
    {
		if(isNaN(obj))
		{  
			alert("非法数字");
        	return false;
		}
     }
	 return true;
}  
function SubmitForm()
{
	var price = $('#productPrice').val();
	if(price=='')
	{
		alert('价格不能为空!');
		return;
	}
	if(price<=0)
	{
		alert('数量不能小于0!');
		$('#productPrice').focus()
		return;
	}
	if(!checkNum(price)) {$('#productPrice').val('');$('#productPrice').focus();return;}
	
	var sum = $('#productSum').val();
	if(sum=='')
	{
		alert('数量不能为空!');
		$('#productSum').focus()
		return;
	}
	if(sum<1)
	{
		alert('数量不能小于1!');
		$('#productSum').focus()
		return;
	}
	if(!checkNum(sum)) {$('#productSum').val('');$('#productSum').focus();return;}
	// ajax发送数据
        $.post('?app=<?php echo APP; ?>&mod=addCar',$('#form').serialize(),function(data){
            if (data.state <= 0)
            {
                alert(data.message);
                return false;
            }
			alert(data.message);
			reloadPage();
        },'json');
        return false;
}

function CannelForm()
{
	CloseWindow();
}


</script>
<form id="form">
	<input type="hidden" id="lid" name="lid" value="<?=$this->lid;?>" />
    <input type="hidden" id="pid" name="pid" value="<?=$this->pid;?>" />
<div class="post_form" id="info_form">
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="info_table">    
		<tr>
			<td class="td1">商品名称：</td>
			<td>
                <span><?=$this->productName;?></span>
        	</td>
		</tr>
        <tr>
			<td class="td1">价格：</td>
			<td>
               <span><input name="productPrice"   id="productPrice" value="<?=$this->productPrice;?>" class="text1" /></span>
        	</td>
		</tr>
        <tr>
			<td class="td1">数量：</td>
			<td>
                <span><input name="productSum"   id="productSum" value="<?=$this->productSum;?>" class="text1" /></span>
        	</td>
		</tr>
        <tr>
        	<td class="td1" colspan="6" style="text-align:center;">
            	<input type="button" onclick="SubmitForm();" value="提交"/>
                <input type="reset"  onclick="CannelForm();" value="取消"/>
            </td>		
		</tr>
     </table>
</div>
</form>